<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/NoFrameTemplate.xhtml">

        <ui:define name="content">
            
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages globalOnly="true" errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <p:panel toggleable="true" id="salesLeadCreate" header="Create a new sales lead">
                    <h:panelGrid columns="3">
                        <h:outputLabel value="CompanyName" for="companyName" />
                        <p:inputText  required ="true" requiredMessage="Company name is missing" 
                                      id="companyName" value="#{salesLeadEntityController.selected.companyName}" title="#{bundle.CreateSalesLeadEntityTitle_companyName}" /> 
                        <h:message styleClass="errorMsg" for= "companyName"/>

                        <h:outputLabel value="JobTitle" for="jobTitle" />
                        <p:inputText id="jobTitle" value="#{salesLeadEntityController.selected.jobTitle}" title="#{bundle.CreateSalesLeadEntityTitle_jobTitle}" required="true" requiredMessage="Job title is missing" />
                        <h:message styleClass="errorMsg" for= "jobTitle"/>

                        <h:outputLabel value="UserName" for="name" />
                        <p:inputText id="name" value="#{salesLeadEntityController.selected.name}" title="#{bundle.CreateSalesLeadEntityTitle_name}" 
                                     required="true" requiredMessage="UserName is missing" 
                                     validator ="#{systemUserEntityController.validateUserName}">
                        </p:inputText>
                        <h:message styleClass="errorMsg" for= "name"/>

                        <h:outputLabel value="Password" for="password" />
                        <p:password id="password" binding="#{password}" value="#{salesLeadEntityController.selected.password}"  minLength="6" feedback="true" required="true" requiredMessage="PassWord is missing"/>
                        <h:message styleClass="errorMsg" for="password" />
                        
                        <h:outputLabel for="confirm" value="Confirm password:" />
                        <p:password id="confirm" required="true" minLength="6" feedback="true" requiredMessage="PassWord is missing">
                          <f:validator validatorId="macTeam.PasswordValidator" />
                          <f:attribute name="password" value="#{password.value}" />
                        </p:password>
                        <h:message styleClass="errorMsg" for="confirm" />

                        <h:outputLabel value="FirstName" for="firstName" />
                        <p:inputText id="firstName" value="#{salesLeadEntityController.selected.firstName}" title="#{bundle.CreateSalesLeadEntityTitle_firstName}" required="true" requiredMessage="First name is missing"/>
                        <h:message styleClass="errorMsg" for= "firstName"/>

                        <h:outputLabel value="#{bundle.CreateSalesLeadEntityLabel_lastName}" for="lastName" />
                        <p:inputText id="lastName" value="#{salesLeadEntityController.selected.lastName}" title="#{bundle.CreateSalesLeadEntityTitle_lastName}" required="true" requiredMessage="Last name is missing"/>
                        <h:message styleClass="errorMsg" for= "lastName"/>

                        <h:outputLabel value="Title" for="title" />
                        <h:selectOneMenu id="title" value="#{salesLeadEntityController.selected.title}" title="#{bundle.CreateSalesLeadEntityTitle_title}" >
                            <f:selectItems value="#{systemUserEntityController.userTitles}"/>
                        </h:selectOneMenu>
                        <h:message styleClass="errorMsg" for= "title"/>

                        <h:outputLabel value="Customer Type: " for="customerType" />
                        <h:selectOneMenu id="customerType" value="#{salesLeadEntityController.selected.customerType}" title="customerType" >
                            <f:selectItems value="#{salesLeadEntityController.customerType}"/>
                        </h:selectOneMenu>                    
                        <h:message styleClass="errorMsg" for= "customerType"/>
                    </h:panelGrid>
                </p:panel>
                <br/>
                <p:panel toggleable="true" id="salesLeadContact" header="Contact Details">
                    <h:panelGrid columns="3">
                        <h:outputLabel value="ContactNumber" />
                        <p:inputText id="ContactNumber" value="#{salesLeadEntityController.selected.contact.contactNumber}" title="#{bundle.CreateSalesLeadEntityTitle_contactNumber}" required="true" requiredMessage="Contact Number is missing" >
                            <f:validator validatorId="macTeam.ContactNumberValidator" />
                        </p:inputText>
                        <h:message styleClass="errorMsg" for= "ContactNumber"/>


                        <h:outputLabel value="Email"  />
                        <p:inputText id="email" value="#{salesLeadEntityController.selected.contact.email}" title="#{bundle.CreateSalesLeadEntityTitle_email}" required="true" requiredMessage="Email is missing" validator ="#{contactEntityController.validateEmail}">
                            <f:validator validatorId="macTeam.EmailValidator" />
                        </p:inputText>
                        <h:message styleClass="errorMsg" for= "email" />                                      

                    </h:panelGrid>


                    <br />
                </p:panel>
                <p:captcha label="Captcha" secure="true" /> 
                <p:commandButton ajax="false" action="#{salesLeadEntityController.createRedirectToIndex}" value="#{bundle.CreateSalesLeadEntitySaveLink}" />              

            </h:form>
        </ui:define>
    </ui:composition>

</html>
